#include "system/assert.h"
#include <logs/Log.h>
#include <Gluck.h>

#include <assert.h>
#if !defined( IPHONE_VERSION ) && !defined( ANDROID_NDK ) && !defined( MARMALADE )
#include <atlstr.h>
#endif

namespace {
	const char* LOGGER = "ASSERT";
}

namespace liba {
namespace system {

void lib_assert(const char * _Message, const char *_File, unsigned _Line)
{
	LOG_FATAL(LOGGER, "\'%s\' in %s:$d", _Message, _File, _Line );

#if !defined( IPHONE_VERSION ) && !defined( ANDROID_NDK ) && !defined( MARMALADE )
#ifdef DEBUG
	_wassert(CA2W(_Message), CA2W(_File), _Line);
#endif
#else
	assert(_Message);
#endif
}

void lib_check(const char * _Message, const char *_File, unsigned _Line)
{
	lib_assert(_Message, _File, _Line);
	THROW(Gluck(_File, _Message));
}

} // namespace system
} // namespace liba